package com.storm.lib.vo;

import java.util.ArrayList;
import java.util.List;

import com.storm.lib.util.StringUtil;



/**
 * 
 * 类功能:掉落表达式
 * @author johnny
 * @version 2011-11-21
 */
public class DropConditionVo {
	private DropConditionItemVo dropConditionItemVo;
	private List<DropConditionItemVo> dropConditionItemVos;
	public DropConditionItemVo getDropConditionItemVo() {
		return dropConditionItemVo;
	}
	public void setDropConditionItemVo(DropConditionItemVo dropConditionItemVo) {
		this.dropConditionItemVo = dropConditionItemVo;
	}
	public List<DropConditionItemVo> getDropConditionItemVos() {
		return dropConditionItemVos;
	}
	public void setDropConditionItemVos(
			List<DropConditionItemVo> dropConditionItemVos) {
		this.dropConditionItemVos = dropConditionItemVos;
	}
	public static List<DropConditionVo> createList(String str){
		if(StringUtil.isEmpty(str)){
			return new ArrayList<DropConditionVo>();
		}
		String[] vals = str.split(";");
		List<DropConditionVo> dropConditionVos = new ArrayList<DropConditionVo>();
		for (String string : vals) {
			DropConditionVo dropConditionVo = new DropConditionVo();
			String[] items = string.split(",");
			if(items.length==1){
				DropConditionItemVo dropConditionItemVo = new DropConditionItemVo();
				dropConditionItemVo.loadProperty(items[0], null);
				dropConditionVo.setDropConditionItemVo(dropConditionItemVo);
			}
			else{
				List<DropConditionItemVo> dropConditionItemVos =new ArrayList<DropConditionItemVo>();
				for (String itemStr : items) {
					DropConditionItemVo dropConditionItemVo = new DropConditionItemVo();
					dropConditionItemVo.loadProperty(itemStr, null);
					dropConditionItemVos.add(dropConditionItemVo);
				}
				dropConditionVo.setDropConditionItemVos(dropConditionItemVos);
			}
			dropConditionVos.add(dropConditionVo);
		}
		return dropConditionVos;
	}
	
}
